<template>
    <div>
        <hd-tab :tabs="tabs"></hd-tab>
        <el-card class="box-card" shadow="never">
            <div slot="header" class="clearfix">
                <span>订单信息</span>
            </div>
            <el-form :model="form" label-width="100px">
                <el-form-item label="ID">
                    <el-input v-model="form.id" disabled></el-input>
                </el-form-item>
                <el-form-item label="服务类型">
                    <el-radio-group v-model="form.service_id" size="mini">
                        <el-radio v-for="(service,index) in services" :key="index" :label="service.id" border>
                            {{ service.name }}
                        </el-radio>
                    </el-radio-group>

                </el-form-item>
                <el-form-item label="订单名称">
                    <el-input v-model="form.name" disabled></el-input>
                </el-form-item>
                <el-form-item label="用户手机">
                    <el-input v-model="form.mobile" disabled></el-input>
                </el-form-item>
                <el-form-item label="用户地址">
                    <el-input v-model="form.address" disabled></el-input>
                </el-form-item>
                <el-form-item label="留言内容">
                    <el-input v-model="form.content" placeholder="留言信息" type="textarea"></el-input>
                </el-form-item>
                <el-form-item label="预约结果">
                    <el-input v-model="form.result" placeholder="预约结果" type="textarea"></el-input>
                </el-form-item>
                <el-form-item label="当前状态">
                    <el-radio-group v-model="form.status">
                        <el-radio :label="'-1'">失败</el-radio>
                        <el-radio :label="'0'">待办</el-radio>
                        <el-radio :label="'1'">成功</el-radio>
                    </el-radio-group>
                </el-form-item>

                <el-form-item label="结束时间">
                    <el-input v-model="form.overtime"></el-input>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input v-model="form.remark"></el-input>
                </el-form-item>
            </el-form>
            <el-button type="success" @click="onSubmit">保存提交</el-button>
        </el-card>
    </div>
</template>

<script>
import tabs from './tabs'

const form = {}
export default {
    route: false,
    props: ['id'],
    data() {
        return {
            tabs,
            form: {},
            services: []
        }
    },

    async created() {
        if (this.id) {
            this.form = await this.axios.get(`admin/order/${this.id}`)
            this.services = await this.axios.get(`admin/service`)
        }
    },
    methods: {
        async onSubmit() {
            const url = this.id ? `admin/order/${this.id}` : `admin/order/${this.id}`;
            await this.axios[this.id ? 'put' : 'post'](url, this.form)
            this.$router.push({name: 'admin.order.index'})
        }
    }
}
</script>

<style scoped>

</style>
